home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C++ für Kids
/
C++ for kids.iso
/
Buch
/
Wexl3.cpp
< prev
next >
Wrap
C/C++ Source or Header
|
1999-01-26
|
2KB
|
71 lines
//---------------------------------------------------------------------------
#include <vcl\vcl.h>
#pragma hdrstop
#include "Wexl3.h"
//---------------------------------------------------------------------------
#pragma resource "*.dfm"
//---------------------------------------------------------------------------
template <class AllTyp>
void ExChange (AllTyp *x, AllTyp *y)
{
AllTyp z = *x; *x = *y; *y = z;
}
template <class AllTyp>
void ShowIt (AllTyp x, AllTyp y)
{
Form1->Panel1->Caption = AllTyp (x);
Form1->Panel2->Caption = AllTyp (y);
}
//---------------------------------------------------------------------------
String Text1, Text2;
double Zahl1, Zahl2;
bool Modus;
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{
Text1 = InputBox
("1. String","BestΣtigen oder NEU","Hallo");
Text2 = InputBox
("2. String","BestΣtigen oder NEU","Hoppla");
ShowIt (Text1, Text2);
Modus = true;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button2Click(TObject *Sender)
{
Zahl1 = StrToFloat (InputBox
("1. Zahl","BestΣtigen oder NEU","0"));
Zahl2 = StrToFloat (InputBox
("2. Zahl","BestΣtigen oder NEU","1"));
ShowIt (Zahl1, Zahl2);
Modus = false;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button3Click(TObject *Sender)
{
if (Modus)
{
ExChange (&Text1, &Text2);
ShowIt (Text1, Text2);
}
else
{
ExChange (&Zahl1, &Zahl2);
ShowIt (Zahl1, Zahl2);
}
}
//---------------------------------------------------------------------------